﻿
(function() {
	var allModules = {
		draggable : {
			js : "jquery.draggable.js"
		},
		resizable : {
			js : "jquery.resizable.js"
		},
		linkbutton : {
			js : "jquery.linkbutton.js",
			css : "linkbutton.css"
		},
		pagination : {
			js : "jquery.pagination.js",
			css : "pagination.css",
			dependencies : ["linkbutton"]
		},
		datagrid : {
			js : "jquery.datagrid.js",
			css : "datagrid.css",
			dependencies : ["resizable", "linkbutton", "pagination"]
		},
		panel : {
			js : "jquery.panel.js",
			css : "panel.css"
		},
		window : {
			js : "jquery.window.js",
			css : "window.css",
			dependencies : ["resizable", "draggable", "panel"]
		},
		dialog : {
			js : "jquery.dialog.js",
			css : "dialog.css",
			dependencies : ["window"]
		},
		messager : {
			js : "jquery.messager.js",
			css : "messager.css",
			dependencies : ["linkbutton", "window"]
		},
		layout : {
			js : "jquery.layout.js",
			css : "layout.css",
			dependencies : ["resizable", "panel"]
		},
		tabs : {
			js : "jquery.tabs.js",
			css : "tabs.css"
		},
		accordion : {
			js : "jquery.accordion.js",
			css : "accordion.css",
			dependencies : ["panel"]
		},
		combobox : {
			js : "jquery.combobox.js",
			css : "combobox.css",
			dependencies : ["validatebox"]
		},
		validatebox : {
			js : "jquery.validatebox.js",
			css : "validatebox.css"	
		},
		filetext : {
			js : "jquery.filetext.js",
			css : "filetext.css",
			dependencies : ["validatebox"]
		},
		parser : {
			js : "jquery.parser.js"
		}
	};
	var allLocales = {
		"en" : "easyui-lang-en.js",
		"zh_CN" : "easyui-lang-zh_CN.js"
	};
	var _3 = {};
	function _4(_5, _6) {
		var _7 = false;
		var _8 = document.createElement("script");
		_8.type = "text/javascript";
		_8.language = "javascript";
		_8.src = _5;
		_8.onload = _8.onreadystatechange = function() {
			if (!_7
					&& (!_8.readyState || _8.readyState == "loaded" || _8.readyState == "complete")) {
				_7 = true;
				_8.onload = _8.onreadystatechange = null;
				if (_6) {
					_6.call(_8);
				}
			}
		};
		document.getElementsByTagName("head")[0].appendChild(_8);
	};
	function _9(_a, _b) {
		_4(_a, function() {
					if ($.browser.msie && $.browser.version == '6.0') {
						$(this).remove();
					} else {
						document.getElementsByTagName("head")[0].removeChild(this);
					}					
					if (_b) {
						_b();
					}
				});
	};
	function _c(_d, _e) {
		var _f = document.createElement("link");
		_f.rel = "stylesheet";
		_f.type = "text/css";
		_f.media = "screen";
		_f.href = _d;
		document.getElementsByTagName("head")[0].appendChild(_f);
		if (_e) {
			_e.call(_f);
		}
	};
	function _10(moduleName) {
		_3[moduleName] = "loading";
		var module = allModules[moduleName];
		var _13 = "loading";
		var _14 = (easyloader.css && module["css"]) ? "loading" : "loaded";
		if (easyloader.css && module["css"]) {
			if (/^http/i.test(module["css"])) {
				var url = module["css"];
			} else {
				var url = easyloader.base + "themes/" + easyloader.theme + "/"
						+ module["css"];
			}
			_c(url, function() {
						_14 = "loaded";
						if (_13 == "loaded" && _14 == "loaded") {
							_15();
						}
					});
		}
		if (/^http/i.test(module["js"])) {
			var url = module["js"];
		} else {
			var url = easyloader.base + "plugins/" + module["js"];
		}
		_4(url, function() {
					_13 = "loaded";
					if (_13 == "loaded" && _14 == "loaded") {
						_15();
					}
				});
		function _15() {
			_3[moduleName] = "loaded";
			easyloader.onProgress(moduleName);
		};
	};
	function _16(module, _18) {
		var p = [];
		var _19 = false;
		if (typeof module == "string") {
			add(module);
		} else {
			for (var i = 0; i < module.length; i++) {
				add(module[i]);
			}
		}
		function add(moduleName) {
			if (!allModules[moduleName]) {
				return;
			}
			//dependencies
			var dependModules = allModules[moduleName]["dependencies"];
			if (dependModules) {
				for (var i = 0; i < dependModules.length; i++) {
					add(dependModules[i]);
				}
			}
			p.push(moduleName);
			if (!_3[moduleName]) {
				_10(moduleName);
				_19 = true;
			}
		};
		function _1b() {
			if (_18) {
				_18();
			}
			easyloader.onLoad(module);
		};
		var _1c = 0;
		(function() {
			var b = true;
			for (var i = 0; i < p.length; i++) {
				if (_3[p[i]] == "loading") {
					b = false;
					break;
				}
			}
			if (b == true) {
				//if (easyloader.locale && _19 == true && allLocales[easyloader.locale]) {
				if (easyloader.locale && allLocales[easyloader.locale]) {
					var url = easyloader.base + "locale/"
							+ allLocales[easyloader.locale];
							
					_9(url, function() {
								_1b();
							});
				} else {
					_1b();
				}
			} else {
				if (_1c < easyloader.timeout) {
					_1c += 10;
					setTimeout(arguments.callee, 10);
				}
			}
		})();
	};
	easyloader = {
		modules : allModules,
		locales : allLocales,
		base : ".",
		theme : "default",
		css : true,
		locale : null,
		timeout : 2000,
		load : function(moduleName, _1e) {
			if (/\.css$/i.test(moduleName)) {
				if (/^http/i.test(moduleName)) {
					_c(moduleName, _1e);
				} else {
					_c(easyloader.base + moduleName, _1e);
				}
			} else {
				if (/\.js$/i.test(moduleName)) {
					if (/^http/i.test(moduleName)) {
						_4(moduleName, _1e);
					} else {
						_4(easyloader.base + moduleName, _1e);
					}
				} else {
					_16(moduleName, _1e);
				}
			}
		},
		onProgress : function(_1f) {
		},
		onLoad : function(_20) {
		}
	};
	var _21 = document.getElementsByTagName("script");
	for (var i = 0; i < _21.length; i++) {
		var src = _21[i].src;
		if (!src) {
			continue;
		}
		var m = src.match(/easyloader\.js(\W|$)/i);
		if (m) {
			easyloader.base = src.substring(0, m.index);
		}
	}
	window.using = easyloader.load;
//	if (window.jQuery) {
//		jQuery(function() {
//					easyloader.load("parser");
//				});
//	}
})();
